extends "ActionFather.gd"

#一次伤害 不包含动画 瞬间完成
func damage(dh,from,to,dmg):
	#死亡不再处理 以后可以加入其它效果
	if from.die|| to.die:
		return null
	#攻击
	hit(dh,to,dmg)
	camShake(dh)
	#计算伤害
	var arm=to.armor
	var hp=to.hp
	arm-=dmg
	var a=0
	if arm<0:
		a=-arm
		arm=0
	if a>0:
		hp-=a
	setProperty(dh,to,"armor",arm)
	setHp(dh,to,hp)
func camShake(dh):
	dh.append({action="camShake"})
func hit(dh,chess,dmg):
	dh.append({action="hit",chess=chess,dmg=dmg})
func die(dh,chess):
	chess.die=true
	Global.Battle.removeChess(chess)
	dh.append({action="die",chess=chess})
func wait(dh,time):
	dh.append({action="wait",time=time})
func forward(dh,chess):
	dh.append({action="forward",chess=chess})
func VETarget(dh,ve,target,isWait=false):
	dh.append({action="VETarget",VE=ve,target=target,isWait=isWait})
func draw():
	Global.CardSystem.draw()
func gainEnergy(number=1):
	Global.CardSystem.energy+=number
func discardRandom():
	Global.CardSystem.discardRandom()
func VEPoint(dh,ve,point,isWait=false):
	dh.append({action="VEPoint",VE=ve,point=point,isWait=isWait})
func setProperty(dh,chess,property,value):
	chess.set(property,value)
	dh.append({action="setProperty",chess=chess,property=property,value=value})
func setPropertyDH(dh,chess,property,value):
	dh.append({action="setProperty",chess=chess,property=property,value=value})
func gainProperty(dh,chess,property,gainValue):
	var value=chess.get(property)+gainValue
	chess.set(property,value)
	dh.append({action="setProperty",chess=chess,property=property,value=value})
func reduceProperty(dh,chess,property,reduceValue):
	var value=chess.get(property)-reduceValue
	chess.set(property,value)
	dh.append({action="setProperty",chess=chess,property=property,value=value})
func gainArmor(dh,chess,armor):
	chess.armor+=armor
	setProperty(dh,chess,"armor",chess.armor)
func setHp(dh,chess,hp):
	if hp>chess.maxHp:
		hp=chess.maxHp
	setProperty(dh,chess,"hp",hp)
	if chess.hp<=0:
		die(dh,chess)